/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package au.edu.swin.unilearn;

import au.edu.swin.unilearn.subject.*;
import au.edu.swin.unilearn.tutorialGroup.*;
import au.edu.swin.unilearn.assignment.*;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.model.SelectItem;

/**
 *
 * @author DidierLeung
 */
public class DownloadAssignmentBean
{
    private static String STAFFID = "912345X";
    @EJB
    private TutorialGroupSessionRemote tutorialGroupSession;
    @EJB
    private AssignmentSessionRemote assignmentSession;
    @EJB
    private SubjectSessionRemote subjectSession;
    private String filterSubjectCode;
    private String filterAssignmentNo;
    private String subjectName;
    private String assignmentName;

    /** Creates a new instance of DownloadAssignmentBean */
    public DownloadAssignmentBean()
    {
    }

    public List<SelectItem> getSubjectCodeItems()
    {
        List<SelectItem> subjectCodeItems = new ArrayList();
        for (TutorialGroup tg : tutorialGroupSession.getTutorialGroupOf(STAFFID))
        {
            Subject s = tg.getSubject();
            SelectItem si = new SelectItem(s.getSubject_code(), s.getSubject_code() + " - " + s.getSubject_name());
            subjectCodeItems.add(si);
        }
        return subjectCodeItems;
    }

    public List<SelectItem> getAssignmentItems()
    {
        List<SelectItem> assignmentItems = new ArrayList();
        System.out.println("Subject Code: " + filterSubjectCode);
        for (Assignment a : assignmentSession.getAllAssignmentForMarking(filterSubjectCode))
        {
            SelectItem si = new SelectItem(a.getAssignment_no(), a.getAssignment_no() + " - " + a.getAssignment_name());
            assignmentItems.add(si);
        }
        return assignmentItems;
    }

    public String getSubmissionAvailable()
    {
        Subject s = subjectSession.getSubject(filterSubjectCode);
        this.setSubjectName(s.getSubject_name());
        return "success";
    }

    public String displayAssignmentSubmission()
    {
        Assignment a = assignmentSession.getAssignment(filterAssignmentNo, filterSubjectCode);
        this.setAssignmentName(a.getAssignment_name());
        return "next";
    }

    
    public String getFilterSubjectCode()
    {
        return filterSubjectCode;
    }

    public void setFilterSubjectCode(String filterSubjectCode)
    {
        this.filterSubjectCode = filterSubjectCode;
    }

    public String getFilterAssignmentNo()
    {
        return filterAssignmentNo;
    }

    public void setFilterAssignmentNo(String filterAssignmentNo)
    {
        this.filterAssignmentNo = filterAssignmentNo;
    }

    public String getSubjectName()
    {
        return subjectName;
    }

    public void setSubjectName(String subjectName)
    {
        this.subjectName = subjectName;
    }

    public String getAssignmentName()
    {
        return assignmentName;
    }

    public void setAssignmentName(String assignmentName)
    {
        this.assignmentName = assignmentName;
    }
}
